package backend;

import org.w3c.dom.Document;
import org.w3c.dom.NodeList;

public class Subcategories {
	private String subcateg[];
	private String url;

        public Subcategories(int categoria){
            url = "http://eiffel.itba.edu.ar/hci/service/Catalog.groovy?method=GetSubcategoryList&language_id=1&category_id="+categoria;
        }

	public void initialize() {
		try{
			Connect con = new Connect();
			Document dom = con.getConection(url);
			NodeList subcategories = dom.getElementsByTagName("name");
			this.subcateg = new String[subcategories.getLength()];
			for(int i=0; i<subcategories.getLength(); i++){
				subcateg[i]=new String(subcategories.item(i).getTextContent());
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	public String[] getSubcategories(){
		return this.subcateg;
	}
	
}
